package com.guoheng.hazard.sys.controller.entpr;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.entpr.EntprMaterialProductInsertDTO;
import com.guoheng.hazard.sys.model.dto.entpr.EntprMaterialProductUpdateDTO;
import com.guoheng.hazard.sys.service.entpr.EntprMaterialProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 类功能描述:　EntprMaterialProductController
 *
 * @author fbl
 * @date 2019-11-12 10:30
 */
@RestController
@Validated
@Api(value = "企业原料产品信息")
public class EntprMaterialProductController {

    @Resource
    EntprMaterialProductService entprMaterialProductService;

    @ApiOperation(value = "查询企业原料产品信息列表")
    @GetMapping(value = "data/basic/enterprise/products")
    public Result getEntprProducts(Long entprId, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize, Integer productType) {
        return entprMaterialProductService.getEntprProducts(entprId, pageNum, pageSize, productType);
    }

    @ApiOperation(value = "修改企业原料产品信息列表")
    @PutMapping(value = "data/basic/enterprise/products")
    public Result updateEntprProducts(@RequestBody @Valid EntprMaterialProductUpdateDTO entprMaterialProductUpdateDTO) {
        return entprMaterialProductService.updateEntprProducts(entprMaterialProductUpdateDTO);
    }

    @ApiOperation(value = "新增企业原料产品信息列表")
    @PostMapping(value = "data/basic/enterprise/products")
    public Result insertEntprProducts(@RequestBody @Valid EntprMaterialProductInsertDTO entprMaterialProductInsertDTO) {
        return entprMaterialProductService.insertEntprProducts(entprMaterialProductInsertDTO);
    }

    @ApiOperation(value = "查询企业原料产品信息详情")
    @GetMapping(value = "data/basic/enterprise/products/{id}")
    public Result selectEntprProductById(@PathVariable @NotNull Long id) {
        return entprMaterialProductService.selectEntprProductById(id);
    }

    @ApiOperation(value = "删除企业原料产品信息")
    @DeleteMapping(value = "data/basic/enterprise/products/{id}")
    public Result deleteEntprProduct(@PathVariable @NotNull Long id) {
        return entprMaterialProductService.deleteEntprProduct(id);
    }
}